package com.solweaver.greetings.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.solweaver.greetings.entity.Event;
import com.solweaver.greetings.entity.EventStatus;
import com.solweaver.greetings.entity.User;

@Repository
public class EventDAO extends BaseDAO<Event, Long >{

	public List<Event> findById(Long eventId, EventStatus eventStatus){
		List<Event> eventList = null;
		
		if(eventId != null){
			eventList = findByCriteria(Restrictions.and(Restrictions.eq("id", eventId), Restrictions.eq("eventStatus", eventStatus)));
		}
		
		return eventList;
	}
	
	public List<Event> findByCreatedUser(User user, EventStatus eventStatus) {
		List<Event> eventList = null;
		if(user != null){
			eventList = findByCriteria(Restrictions.and(Restrictions.eq("createdBy", user), Restrictions.eq("eventStatus", eventStatus)));
		}
		return eventList;
	}

}
